//package com.smcdd.cdb.dbo.cdb_dbo.ui.adapter;
//
//import android.content.Context;
//import android.support.v4.view.PagerAdapter;
//import android.support.v4.widget.SwipeRefreshLayout;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ImageView;
//
//import com.smcdd.cdb.dbo.cdb_dbo.R;
//import com.smcdd.cdb.dbo.cdb_dbo.app.App;
//import com.smcdd.cdb.dbo.cdb_dbo.network.HttpObserver;
//import com.smcdd.cdb.dbo.cdb_dbo.network.factory.RetrofitFactory;
//import com.smcdd.cdb.dbo.cdb_dbo.service.entity.BaseResponseEntity;
//import com.smcdd.cdb.dbo.cdb_dbo.service.entity.MainTenance;
//import com.smcdd.cdb.dbo.cdb_dbo.service.maneger.NetWorkCodeInfo;
//import com.smcdd.cdb.dbo.cdb_dbo.ui.utils.DateUtils;
//import com.smcdd.cdb.dbo.cdb_dbo.ui.utils.ObtainEncry;
//import com.smcdd.cdb.dbo.cdb_dbo.ui.utils.ObtainVersion;
//import com.smcdd.cdb.dbo.cdb_dbo.ui.utils.ToastUtil;
//import com.smcdd.cdb.dbo.cdb_dbo.ui.widget.TainDialog;
//
//import java.util.LinkedHashMap;
//import java.util.List;
//import java.util.Map;
//
//import rx.android.schedulers.AndroidSchedulers;
//import rx.schedulers.Schedulers;
//
///**
// * 作者：Administrator on 2017/8/5 19:04
// * 邮箱：zhanghuaiha@gmail.com
// */
//
//public class TainPagerAdapter extends PagerAdapter {
//    private final String versionCode;
//    private final String id;
//    private final String udid;
//    private Context context;
//    private LinearLayoutManager linearLayoutManager;
//    private TainAdapter tainAdapter;
//    private RecyclerView recyclerView;
//    private String date = "";
//    private TainDialog listDialog;
//
//    public TainPagerAdapter(Context context){
//        this.context=context;
//        versionCode = ObtainVersion.getVersionName(context);
//        id = App.SP.getString("id", "");
//        udid = App.SP.getString("udid", "");
//    }
//
//    @Override
//    public int getCount() {
//        return Integer.MAX_VALUE;
//    }
//
//    @Override
//    public boolean isViewFromObject(View view, Object object) {
//        return view==object;
//    }
//
//    @Override
//    public void destroyItem(ViewGroup container, int position, Object object) {
//        container.removeView((View) object);
//    }
//
//    @Override
//    public Object instantiateItem(ViewGroup container, int position) {
//        //getView
//        View view = View.inflate(context, R.layout.item_tain_pager, null);
//        recyclerView = (RecyclerView) view.findViewById(R.id.maintain_recycler);
//        SwipeRefreshLayout page_srl = (SwipeRefreshLayout) view.findViewById(R.id.maintain_srl);
//        linearLayoutManager = new LinearLayoutManager(context);
//        recyclerView.setLayoutManager(linearLayoutManager);
//        setAdapter();
//        //添加到容器中
//        container.addView(view);
//        return view;
//    }
//
//    private void setAdapter() {
//        if (tainAdapter == null) {
//            tainAdapter = new TainAdapter(context);
//        }
//        recyclerView.setAdapter(tainAdapter);
//        tainAdapter.setItemClickListenter((dataBean, position) -> {
//            long l = 0;
//            if (this.date!= null&&!this.date.equals("")) {
//                long time_long = DateUtils.getTime_long(date);
//                l = time_long - 86400000;
//            }else {
//                l = System.currentTimeMillis() - 86400000;
//            }
//            String time = DateUtils.getTime(l);
//            loadDiaolog(time,dataBean.getCharging_info_ids());
//        });
//    }
//
//    /**
//     * 获取dialog数据
//     * @param date
//     * @param charging_info_ids
//     */
//    public void loadDiaolog(String date,String charging_info_ids){
//        String time = System.currentTimeMillis() + "";
//        Map<String,String> map = new LinkedHashMap<>();
//        map.put("rf","2");
//        map.put("ts",time);
//        map.put("v", versionCode);
//        map.put("i", NetWorkCodeInfo.MAINTENANCE_CHARGING);
//        map.put("udid", udid);
//        map.put("eid", id);
//        map.put("date",date);
//        map.put("charging_info_ids",charging_info_ids);
//        String encry1 = ObtainEncry.getEncry(map);
//        map.put("encry",encry1);
//        RetrofitFactory.getmInstanse().mApi.getmaintenance(map)
//                .subscribeOn(Schedulers.io())
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(new HttpObserver<BaseResponseEntity<List<MainTenance>>>() {
//                    @Override
//                    public void success(BaseResponseEntity<List<MainTenance>> mainTenanceBaseResponseEntity) {
//                        if (mainTenanceBaseResponseEntity.code == 200) {
//                            List<MainTenance> data = mainTenanceBaseResponseEntity.data;
//                            Dialog(data);
//                        }
//                    }
//                    @Override
//                    public void onError(Throwable e) {
//                        super.onError(e);
//                        ToastUtil.showToast(context.getString(R.string.error_date));
//                    }
//                });
//    }
//
//    public void Dialog( List<MainTenance> data) {
//        listDialog = new TainDialog(context,data);
//        listDialog.show();
//    }
//}
